<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <title>分配规则</title>
    <link href='Public/hdjs/hdjs.css' rel='stylesheet' media='screen'>
    <link rel="stylesheet" type="text/css" href="Public/Admin/css/mod.base.css"/>
    <script type='text/javascript' src='Public/Admin/js/jquery-1.8.2.min.js'></script>
    <script type='text/javascript' src='Public/hdjs/hdjs.min.js'></script>
    <script type='text/javascript' src='Public/hdjs/lhgcalendar.min.js'></script>
    <script src="Public/Admin/js/mod.base.js" type="text/javascript" charset="utf-8"></script>
    <script src="Public/Admin/js/mod.rule.js" type="text/javascript" charset="utf-8"></script>
    <style>
	fieldset{
		border: 1px dotted #ccc;
		padding:10px 10px;
		margin: 20px 0;
	}
	h2{
		padding: 0 10px;
	}
	fieldset label{
		margin-right:10px;
	}
    </style>
<script type="text/javascript">

$(function(){


  $('[type=checkbox]').click(function() {

      var value = $(this).val();
      if(value == 0)
        return ;

      if($(this).attr('checked')=='checked')
      {
        $('[pid='+value+']').attr('checked',true);
        $('.'+value).attr('checked',true);
      }
      else
      {
         $('[pid='+value+']').attr('checked',false);
         $('.'+value).attr('checked',false);
      }



      // 子级别选中一个父级就要被选中
      var cid =  $(this).attr('class');
      $('.'+cid+':checked').length?$('#node'+cid).attr('checked',true):$('#node'+cid).attr('checked',false);

      var id  =  $(this).attr('pid');
      $('[pid='+id+']:checked').length?$('#node'+id).attr('checked',true):$('#node'+id).attr('checked',false);

  });


})

</script>
</head>
<body>
    <form action="" method="post" class="hd-form" name="form" >
        <div class="hd-menu-list">
            <ul>
                <li >
                    <a href="<?php echo U('AuthGroup/index')?>">用户组列表</a>
                </li>
                <li class="active">
                    <a href="javascript:;">设置规则</a>
                </li>
            </ul>
        </div>

        <div class="hd-title-header">设置规则</div>
        <div class="right_content">
            <table class="hd-table hd-table-form">
                <tbody>
                	<?php foreach ($data as $v){?>
	                    <tr>
	                        <td>
	                            <h2>
	                            	<label>
	                            		<input pid='0'  type="checkbox" value="<?php echo $v['id']?>" id="node<?php echo $v['id']?>" name="rules[]" <?php if(in_array($v['id'],$filed)){?>
                 checked="checked" 
               <?php }?> /> <?php echo $v['title']?>
	                            	</label>
	                            </h2>
	                            <?php foreach ($v['_data'] as $value){?>
	                        	<fieldset>

		                           <legend>
		                            	<label><input pid="<?php echo $v['id']?>" type="checkbox" value="<?php echo $value['id']?>"  id="node<?php echo $value['id']?>" name="rules[]" <?php if(in_array($value['id'],$filed)){?>
                 checked="checked" 
               <?php }?>/> <?php echo $value['title']?></label>
		                            </legend>

		                            	<?php foreach ($value['_data'] as $re){?>
				                            <label>
				                            	<input pid="<?php echo $v['id']?>" type="checkbox" value="<?php echo $re['id']?>" class="<?php echo $value['id']?>" name="rules[]" <?php if(in_array($re['id'],$filed)){?>
                 checked="checked" 
               <?php }?>/> <?php echo $re['title']?>
				                            </label>
		                				      <?php }?>

	                            </fieldset>
	                	<?php }?>
	                        </td>
	                    </tr>
                	<?php }?>
                </tbody>
            </table>
        </div>
        <input type="hidden" name="id" value="<?php echo $_GET['id']?>" />
        <input type="submit" value="分配规则" class="hd-btn hd-btn-sm">
        <input type="button" value="返回" class="hd-btn hd-btn-sm" onclick="location.href='<?php echo U('Authgroup/index')?>'">
        </form>
</body>
</html>